# -*- coding: utf-8 -*-
# @Time : 2024/3/7 16:40
# @Author : ZH
# @File : 49.py
# @Software: PyCharm
from typing import List


class Solution(object):
    def groupAnagrams(self, strs: List[str]):
        """
        :type strs: List[str]
        :rtype: List[List[str]]
        """
        data_dict = {}
        for i in strs:
            sort_str = ''.join(sorted(i))
            if data_dict.get(sort_str):
                data_dict[sort_str].append(i)
            else:
                data_dict[sort_str] = [i]
                # data_dict[sort_str].append(i)
        return list(data_dict.values())


if __name__ == '__main__':
    so = Solution()
    z = so.groupAnagrams(["eat", "tea", "tan", "ate", "nat", "bat"])
    print(z)


